import mongoose, { Document, Schema } from 'mongoose';
import { IUser } from './User';

export interface ITeam extends Document {
  name: string;
  description?: string;
  owner: IUser['_id']; // 【新增】队长字段
  members: (IUser['_id'])[];
}

const TeamSchema: Schema = new Schema({
  name: { type: String, required: true, unique: true },
  description: { type: String },
  owner: { type: Schema.Types.ObjectId, ref: 'User', required: true }, // 【新增】
  members: [{ type: Schema.Types.ObjectId, ref: 'User' }]
}, { timestamps: true });

export default mongoose.model<ITeam>('Team', TeamSchema);